#!/usr/bin/sh

help="
Usage:
  fuck <command> [options]

Commands:
  pip                         更换pip下载源：1.阿里云；2.中科大；3.清华；else.官方源。
  windows                     处理来自windows文件的乱码
  run                         赋予文件可执行权限
  git                         永久保存git密码
  time                        修复linux和windows的时间差
  
General Options:
  -h, --help                  Show help.
  -v, --version               Show version.
" 

if [ "$#" = "0" ]
then
	echo "$help"
elif [ "$1" = "pip" ]
then
	if [ "$2" = "1" ]
	then
		pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
	elif [ "$2" = "2" ]
	then
		pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/
	elif [ "$2" = "3" ]
	then
		pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
	else
		pip config set global.index-url https://pypi.python.org/simple
	fi

elif [ "$1" = "windows" ]
then
	sed -i 's/\r$//' $2
elif [ "$1" = "run" ]
then
	chmod +x $2
elif [ "$1" = "git" ]
then
	git config --global credential.helper store
elif [ "$1" = "time" ]
then
	timedatectl set-local-rtc 1 --adjust-system-clock
elif [ "$1" = "-h" -o "$1" = "--help" ]
then
	echo "$help"
elif [ "$1" = "-v" -o "$1" = "--version" ]
then
        echo "fuck-0.0.2 Author: Zhang" 
elif [ "$1" = "ibus" ]
then
		rm -rf .cache/ibus/libpinyin/
		ibus-daemon -rdx
else
	echo "$help"
fi

